package com.kmxd.ams.core.util;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 获取系统软件版本
 *
 * @author zuolg
 */
@Slf4j
@Component
public class AppInfoUtil {

  @Value("${app.version}")
  private String buildVersion;

  @Value("${app.timestamp}")
  private String buildTimestamp;

  public String getVersion() {
    return buildVersion;
  }

  public String getBuildTime() {
    try {
      DateTime date = DateUtil.parse(buildTimestamp, DatePattern.NORM_DATETIME_PATTERN);
      date.setHours(date.getHours() + 8);
      return DateUtil.format(date, DatePattern.NORM_DATETIME_PATTERN);
    } catch (Exception e) {
      log.info("获取编译时间异常！" + e.getMessage());
    }
    return null;
  }
}
